<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script type="text/javascript" src="../js/jquery-3.1.0.min.js"></script>
<script type="text/javascript">
var currentPage=${currentPage };
var totalPage=${totalPage }
$(document).ready(function(){
	$(".page:eq(0)").click(function(){
		currentPage=1;
		getList();
	});
	$(".page:eq(1)").click(function(){
		if(currentPage==1){
			alert("已经是第一页")
		}else{
			currentPage--;
			getList();
		}
	});
	$(".page:eq(2)").click(function(){
		if(currentPage==totalPage){
			alert("已经是最后页")
		}else{
			currentPage++;
			getList();
		}
	});
	$(".page:eq(3)").click(function(){
		currentPage=totalPage;
		getList();
	});
	
	function getList(){
		var namekey=$(":text:eq(0)").val();
		location.href="GetOrderListServlet?namekey="+namekey+"&currentPage="+currentPage;
	}
	function state(id,orderState){
		orderState==2;
			location.href="OrderPayServlet?id="+id+"&orderState="+orderState+"&currentPage="+currentPage;
	}
	function os(orderState){
		if(orderState==0){
			$("#os").html("未付款");
			$(":button:eq(1)").hide();
		}
		if(orderState==1){
			$("#os").html("已付款未发货");
		}
		if(orderState==2){
			$("#os").html("已发货");
			$(":button:eq(1)").hide();
		}
		if(orderState==3){
			$("#os").html("已收货完成");
			$(":button:eq(1)").hide();
		}
	}
	
});
</script>
</head>
<body>
查询订单列表:<input type="text" value="${param.namekey }" name="namekey">
<input type="button" value="搜索">
<table border="1" width="80%">
	<tr>
		<th>商品名称</th><th>价格</th><th>数量</th><th>总价</th><th>状态</th>
		<th>操作</th>
	</tr>
<c:forEach items="${list }" var="b">
	<tr>
		<td>${b.goods.goodsName }</td>
		<td>${b.goods.goodsPrice }</td>
		<td>${b.goodsNum }</td>
		<td>${b.goods.goodsPrice }*${b.goodsNum }</td>
		<td id="os" onclick="os(${b.orderState });"></td>
		<td>
			<input type="button" value="发货" onclick="state(${b.goodsId },${b.orderState })">
		</td>
	</tr>
</c:forEach>
</table>
<input type="button" value="第一页" class="page">
<input type="button" value="上一页" class="page">
<input type="button" value="下一页" class="page">
<input type="button" value="最后页" class="page">
${currentPage }/${totalPage }
</body>
</html>